<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>企业员工工资管理-编辑考勤</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >月出勤管理</a>
        <a>
          <cite>编辑考勤信息</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
</br>
<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form" action="">
        <input type="hidden" id="maId" value="">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
            <legend>时间</legend>
        </fieldset>
        <div class="layui-form-item" style="">
            <label class="layui-form-label">月份</label>
            <div class="layui-input-inline">
                <input type="tel" id="attendanceTime" name="attendanceTime" disabled
                       autocomplete="off"
                       class="layui-input" value="" style="width: 100px"/>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
            <legend>员工信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label" style="">工号</label>
            <div class="layui-input-inline">
                <input type="text" id="eAccount" name="eAccount" disabled  autocomplete="off"
                       class="layui-input" value="" style="width: 100px"/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">部门</label>
            <div class="layui-input-inline">
                <input type="tel" id="dName" name="dName" disabled autocomplete="off"
                       class="layui-input" style="width: 100px" value=""/>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
            <legend>请假天数</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">病假</label>
            <div class="layui-input-inline">
                <input type="text" name="sickLeaveNum" id="sickLeaveNum" lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">事假</label>
            <div class="layui-input-inline">
                <input type="text" name="compassionateLeaveNum" id="compassionateLeaveNum" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
            <legend>加班小时</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">平时加班</label>
            <div class="layui-input-inline">
                <input type="text" name="overtimeHour" id="overtimeHour" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">周末加班</label>
            <div class="layui-input-inline">
                <input type="text" name="weekendHour" id="weekendHour" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">节假日加班</label>
            <div class="layui-input-inline" style="">
                <input type="text" name="holidayHour" id="holidayHour" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
            <legend>考勤情况</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">迟到次数</label>
            <div class="layui-input-inline">
                <input type="text" name="lateNum" id="lateNum" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">早退次数</label>
            <div class="layui-input-inline">
                <input type="text" name="earlyNum" id="earlyNum" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">缺勤次数</label>
            <div class="layui-input-inline">
                <input type="text" name="absenceNum" id="absenceNum" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
            <label class="layui-form-label" style="margin-left: -100px">出差天数</label>
            <div class="layui-input-inline">
                <input type="text" name="businessTravelNum" id="businessTravelNum" required lay-verify="number" autocomplete="off"
                       class="layui-input" style="width: 50px" value=""/>
            </div>
        </div>
        <!--<div class="layui-input-inline" style="margin-left:100px ">-->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="attendanceUpdate">确定</button>
            </div>
        </div>
    </form>

</div>



<script>

    //加载参数
    window.onload = function() {
        //加载maid
        $("#eAccount").val(decodeURI(getQueryVariable("eAccount")));
        //加载工号
        $("#dName").val(decodeURI(getQueryVariable("dName")));
        //根据maid请求数据
        var maId = decodeURI(getQueryVariable("maId")) ;
        $.ajax({
            type:'post',
            url:'monthlyattendance/selectVoByPrimaryKey.do',
            data: {"id": maId},
            dataType:'json',
            success:function(data){
                //加载列表信息
                $("#maId").val(maId);
                $("#attendanceTime").val(data.monthlyAttendance.attendanceTime);
                $("#sickLeaveNum").val(data.monthlyAttendance.sickLeaveNum);
                $("#compassionateLeaveNum").val(data.monthlyAttendance.compassionateLeaveNum);
                $("#overtimeHour").val(data.monthlyAttendance.overtimeHour);
                $("#weekendHour").val(data.monthlyAttendance.weekendHour);
                $("#holidayHour").val(data.monthlyAttendance.holidayHour);
                $("#lateNum").val(data.monthlyAttendance.lateNum);
                $("#earlyNum").val(data.monthlyAttendance.earlyNum);
                $("#absenceNum").val(data.monthlyAttendance.absenceNum);
                $("#businessTravelNum").val(data.monthlyAttendance.businessTravelNum);
            }

        });

    }
    //获取url参数
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var index = query.indexOf("?");
        query = query.substr(index+1,query.length);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){
                return pair[1];
            }
        }
        return false;
    }

    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        //自定义验证规则

        // 监听提交
        form.on('submit(attendanceUpdate)', function(data){
            $.ajax({
                type:'post',
                url:'monthlyattendance/updateAttendance.do',
                data: {
                    "maId":parseInt($("#maId").val()),
                    "sickLeaveNum": parseInt($("#sickLeaveNum").val()),
                    "compassionateLeaveNum": parseInt($("#compassionateLeaveNum").val()),
                    "overtimeHour": parseFloat($("#overtimeHour").val()),
                    "weekendHour": parseFloat($("#weekendHour").val()),
                    "holidayHour": parseFloat($("#holidayHour").val()),
                    "lateNum": parseInt($("#lateNum").val()),
                    "earlyNum": parseInt($("#earlyNum").val()),
                    "absenceNum": parseInt($("#absenceNum").val()),
                    "businessTravelNum": parseInt($("#businessTravelNum").val())
                },
                dataType:'json',
                success:function(result){
                	if(result.code==100){
                		  layer.alert("修改考勤成功", {
                              title: '修改信息'
                          }
                      )
                	}else{
                		layer.msg(result.message);
                	}
                },
                error:function () {
                    layer.msg("网络错误");
                }

            });
            return false;
        });
    });
</script>

</body>

</html>